package parser;


/**
 * Enumeration that provides the different sorts of Token
 * @author sebastian
 *
 */
public enum TokenType {
	// Special Tokens
	ERR("", false),
	EOF("", false),

	// Separators
	ANALYSIS("ANALYSIS", true),
	ALGORITHM("ALGORITHM", true),
	OUTPUT("OUTPUT", true),
	PROGRAM("PROGRAM", true),
	
	START("START", true),
	END("END", true),
	
	AVAILEXPR("Available_Expressions", true),
	TRULYLIVE("Truly_Live_Variables", true),
	INTERVAL("Interval_Analysis", true),
	
	WORKLIST("Worklist", true),
	RROBIN("Round_Robin", true),
	RECURSIVE("Recursive", true),
	
	OUTANA("Analysis", true),
	OUTTRANS("Transformation", true),
	
	MEMORY("M", true),
	
	POS("Pos", true),
	NEG("Neg", true),
	LPAREN("(", false),
	RPAREN(")", false),
	LSQUARE("[", false),
	RSQUARE("]", false),
	SEMI(";", false),
		
	// Literals and Identifiers
	IDENT("", false),
	INT_LITERAL("", false),
	
	// Variable Assignment
	ASSIGN("=", false),
	
	// Arithmetic
	MUL("*", false),
	DIVORSLASH("/", false),
	PLUS("+", false),
	MINUS("-", false),
	LT("<", false),
	LE("<=", false),
	GT(">", false),
	GE(">=", false),
	EQ("==", false),
	NE("!=", false);

	/**
	 * The character representation of this token
	 */
	private final String text;

	/**
	 * true, if this token types text is a keyword
	 */
	private final boolean isKeyword;

	/**
	 * Creates a new token type for the given parameters.
	 *
	 * @param text      			The character representation of this token
	 * @param isKeyword  			true, if this token types text is a keyword
	 */
	private TokenType(String text, boolean isKeyword) {
		this.text = text;
		this.isKeyword = isKeyword;
	}

	/**
	 * Returns the character representation of this token type.
	 *
	 * @return {@link #text}
	 */
	public String getText() {
		return text;
	}

	/**
	 * String representation of this TokenType
	 * 
	 * @return a String representation of this TokenType
	 */
	public String toString() {
		return text.length() > 0 ? text : name();
	}

	/**
	 * Returns true, if this token types text is a keyword.
	 *
	 * @return {@link #isKeyword}
	 */
	public boolean isKeyword() {
		return isKeyword;
	}
}
